<!DOCTYPE HTML>
<html>
<body>
  <ul>
    <li>Animals
      <ul>
        <li>Mammals
          <ul>
            <li>Cows</li>
            <li>Donkeys</li>
            <li>Dogs</li>
            <li>Tigers</li>
          </ul>
        </li>
        <li>Other
          <ul>
            <li>Snakes</li>
            <li>Birds</li>
            <li>Lizards</li>
          </ul>
        </li>
      </ul>
    </li>
    <li>Fishes
      <ul>
        <li>Aquarium
          <ul>
            <li>Guppy</li>
            <li>Angelfish</li>
          </ul>
        </li>
        <li>Sea
          <ul>
            <li>Sea trout</li>
          </ul>
        </li>
      </ul>
    </li>
  </ul>

  <script>
    function getLiTextCount (liEl) {
      let liList = liEl.querySelectorAll('li')
      let name = liEl.firstChild.data
      console.log(`${name}:${liList.length}`)
    }
    let liList = document.querySelectorAll('li')
    for (const liItem of liList) {
      getLiTextCount(liItem)
    }
  </script>
</body>
</html>